{         PalmAPI
Version 7 - November 24, 2004

PalmAPI is a set of common
Palm OS API calls and types
definitions for the
Palm OS Pascal Compiler

Made by Laurent Duveau
      & Philippe Guillot
  web site = www.aldweb.com
  web site = http://ppcompiler.free.fr
  e-Mail   = info@aldweb.com
  e-Mail   = ph.guillot@wanadoo.fr


Use: insert {$i PalmAPI.pas}
     in your PP source code
}


// Palm OS Types Definitions

Const
 SYSTRAP = $4E4F;
 HIGH_DENSITY_TRAP = $A3EC;
 VFS_TRAP = $A348;
 
 nilEvent              = 0;
 penDownEvent          = 1;
 penUpEvent            = 2;
 penMoveEvent          = 3;
 keyDownEvent          = 4;
 winEnterEvent         = 5;
 winExitEvent          = 6;
 ctlEnterEvent         = 7;
 ctlExitEvent          = 8;
 ctlSelectEvent        = 9; 
 ctlRepeatEvent        = 10;
 lstEnterEvent         = 11;
 lstSelectEvent        = 12;
 lstExitEvent          = 13;
 popSelectEvent        = 14;
 fldEnterEvent         = 15;
 fldHeightChangedEvent = 16;
 fldChangedEvent       = 17;
 tblEnterEvent         = 18;
 tblSelectEvent        = 19;
 daySelectEvent        = 20;
 menuEvent             = 21;
 appStopEvent          = 22; 
 frmLoadEvent          = 23;
 frmOpenEvent          = 24;
 frmGotoEvent          = 25;
 frmUpdateEvent        = 26;
 frmSaveEvent          = 27;
 frmCloseEvent         = 28;
 frmTitleEnterEvent    = 29;
 frmTitleSelectEvent   = 30;
 tblExitEvent          = 31;
 sclEnterEvent         = 32;
 sclExitEvent          = 33;
 sclRepeatEvent        = 34;

 firstUserEvent = $6000;

 dmModeReadOnly  = 1;
 dmModeWrite     = 2;
 dmModeReadWrite = 3;

 evtWaitForever = -1;

 noPreferenceFound = -1;

 sndInfo         = 1;
 sndWarning      = 2;
 sndError        = 3;
 sndStartUp      = 4;
 sndAlarm        = 5;
 sndConfirmation = 6;
 sndClick        = 7;

 sysAppLaunchCmdNormalLaunch = 0;
 sysAppLaunchCmdOpenDB       = 52;

 noFrame         = 0;
 simpleFrame     = 1;
 rectangleFrame  = 1;
 simple3DFrame   = $12;
 roundFrame      = $401;
 boldRoundFrame  = $702;
 popupFrame      = $205;
 dialogFrame     = $302;
 
 noFocus         = $FFFF;

 stdFont              = 0;
 boldFont             = 1;
 largeFont            = 2;
 symbolFont           = 3;
 symbol11Font         = 4;
 symbol7Font          = 5;
 ledFont              = 6;
 largeBoldFont        = 7;
 fntAppFontCustomBase = 128;

 sysFtrCreator = $70737973;  // 'psys'
 sysFtrNumWinVersion = 24;

 vfsIteratorStart = 0;
 vfsIteratorStop  = $FFFFFFFF;
 vfsFtrIDVersion  = 0;

Type
 Byte      = 0..255;
 Int16     = -32768..32767;
 UInt16    = 0..65535;
 Int8      = -128..127;
 UInt8     = 0..255;
 Int32     = Integer;
 UInt32    = 0..MaxInt;
 WChar     = UInt16;
 StringPtr = ^String;
 LocalID   = UInt32;
 Err       = UInt16;
 Coord     = UInt16;

 Opaque    = record end;
 MemHandle = ^Opaque;
 ListPtr   = ^Opaque;
 FieldPtr  = ^Opaque;

 MemPtr    = Pointer;
 DmOpenRef = Pointer;

 PointType = record
              x,y:Coord;
             end;

 EventType = record
              eType:UInt16;
              penDown:Boolean;
              tapCount:UInt8;
              screenX,screenY:Int16;
              case integer of
               0: (datum:array[0..7] of UInt16);
               1: (PenUp:record start,finish:PointType end);
               2: (chrc:WChar;keyCode,modifiers:UInt16);
               3: (FrmLoad:record FormID:UInt16 end);
               4: (ctlSelect:record controlID:UInt16;pControl:pointer;on:Boolean;reserved1:UInt8;value:UInt16 end);
               5: (menu:record itemID:UInt16 end);
               6: (ctlEnter:record controlID:UInt16;pControl:pointer end);
               7: (ctlRepeat:record controlID:UInt16;pControl:pointer;time:UInt32;value:UInt16 end);
               8: (sclRepeat:record scrollBarID:UInt16;pScrollbar:pointer;value,newValue:Int16;time:UInt32 end);
               9: (popSelect:record controlID:UInt16;pcontrol:pointer;listID:UInt16;plist:pointer;selection,priorselection:Int16 end);
               10:(frmTitleEnter:record formID:UInt16 end);
              end;

 AbsRectType = record
                left,top,right,bottom:Coord;
               end;

 FrameType = UInt16;
              
 RectangleType = record
                  topLeft,extent:PointType;
                 end;

 BitmapType = record end;
 BitmapPtr  = ^BitmapType;

 RGBColorType = record
                 index,r,g,b:UInt8;
                end;

 IndexedColorType = UInt8;
// 0..215 combination of
//    ff cc 99 66 33 00
// B : 0 6 12 108 114 120
// R : 0 18 36 54 72 90
// G : 0 1 2 3 4 5
// e.g  12+54+5 = $99 B + $66 R +$0 G
// 216..224
// gray 22 44 55 77 88 aa bb dd
// 225..229 = specials: light gray,marron,purple,green,cyan
// 230..255 = unused (black)

 FrameBitsType = record
                  bits,word:UInt16;
                 end;

 WinHandle  = ^WindowType;
 WindowType = record end;

 FormObjListType = record end;

 FormType = record end;
 FormPtr  = ^FormType;

 MenuBarPtr  = ^MenuBarType;
 MenuBarType = record end;

 ControlPtr  = ^ControlType;
 ControlType = record end;

 DmSearchStateType = record
                      info:array[0..7] of UInt32;
                     end;

 clipboardFormatType=(
  clipboardText,
  clipboardInk,
  clipboardBitmap);

 FontID=UInt8;

 UnderlineModeType=(
  noUnderline,
  grayUnderline,
  solidUnderline,
  colorUnderline);

 WinScreenModeOperation=(
  winScreenModeGetDefaults,
  winScreenModeGet,
  winScreenModeSetToDefaults,
  winScreenModeSet,
  winScreenModeGetSupportedDepths,
  winScreenModeGetSupportsColor);

 WinDirectionType=(
  WinUp,
  WinDown,
  WinLeft,
  WinRight);
  
 WinDrawOperation=(
  winPaint,
  winErase,
  winMask,
  winInvert,
  winOverlay,
  winPaintInverse,
  winSwap);

 ScrollBarType = opaque;
 ScrollBarPtr  = ^ScrollBarType;

 DateTimeType = record
	         second,minute,hour,day,month,year,weekDay:Int16;
	        end;
 DateTimePtr = ^DateTimeType;

 DateFormatType=(
  dfMDYWithSlashes,    // 12/31/95
  dfDMYWithSlashes,    // 31/12/95
  dfDMYWithDots,       // 31.12.95
  dfDMYWithDashes,     // 31-12-95
  dfYMDWithSlashes,    // 95/12/31
  dfYMDWithDots,       // 95.12.31
  dfYMDWithDashes,     // 95-12-31
  dfMDYLongWithComma,  // Dec 31, 1995
  dfDMYLong,           // 31 Dec 1995
  dfDMYLongWithDot,    // 31. Dec 1995
  dfDMYLongNoDay,      // Dec 1995
  dfDMYLongWithComma,  // 31 Dec, 1995
  dfYMDLongWithDot,    // 1995.12.31
  dfYMDLongWithSpace,  // 1995 Dec 31
  dfMYMed,             // Dec '95
  dfMYMedNoPost);      // Dec 95      (added for French 2.0 ROM)

 TimeFormatType=(
  tfColon,
  tfColonAMPM,         // 1:00 pm
  tfColon24h,          // 13:00
  tfDot,
  tfDotAMPM,           // 1.00 pm
  tfDot24h,            // 13.00
  tfHoursAMPM,         // 1 pm
  tfHours24h,          // 13
  tfComma24h);         // 13,00

 SelectDayType=(
  selectDayByDay,      // return d/m/y
  selectDayByWeek,     // return d/m/y with d as same day of the week
  selectDayByMonth);   // return d/m/y with d as same day of the month

 SysBatteryKind=(
  sysBatteryKindAlkaline=0,
  sysBatteryKindNiCad,
  sysBatteryKindLiIon,
  sysBatteryKindRechAlk,
  sysBatteryKindNiMH,
  sysBatteryKindLiIon1400,
  sysBatteryKindLast=255); // insert new battery types BEFORE this one

 DlkSyncStateType=(
  dlkSyncStateNeverSynced=0,         // never synced
  dlkSyncStateInProgress,            // sync is in progress
  dlkSyncStateLostConnection,        // connection lost during sync
  dlkSyncStateLocalCan,              // cancelled by local user on handheld
  dlkSyncStateRemoteCan,             // cancelled by user from desktop
  dlkSyncStateLowMemoryOnTD,         // sync ended due to low memory on handheld
  dlkSyncStateAborted,               // sync was aborted for some other reason
  dlkSyncStateCompleted,             // sync completed normally
  // Added in PalmOS v3.0:
  dlkSyncStateIncompatibleProducts); // sync ended because desktop HotSync product
                                     // is incompatible with this version
                                     // of the handheld HotSync
 LocalIDKind=(
  memIDPtr,
  memIDHandle);
   
 FileInfoPtr = ^FileInfoType;
 FileInfoType = record
                 attributes:UInt32;
                 nameP:Pointer;          // buffer to receive full name; pass NULL to avoid getting name
                 nameBufLen:UInt16;      // size of nameP buffer, in bytes
                end;

 WinScreenAttrType=(
  winScreenWidth,
  winScreenHeight,
  winScreenRowBytes,
  winScreenDepth,
  winScreenAllDepths,
  winScreenDensity,
  winScreenPixelFormat,
  winScreenResolutionX,
  winScreenResolutionY);

	
// Palm OS API calls

function  BmpCreate(width,height:Coord;depth:UInt8;colortableP:pointer;var error:UInt16):BitmapPtr; inline(SYSTRAP,$A3DD);

procedure ClipboardAddItem(format:ClipboardFormatType;var ptr;length:UInt16); inline(SYSTRAP,$A10A);
function  ClipboardGetItem(format:ClipboardFormatType;var length:UInt16):MemHandle;inline(SYSTRAP,$A10C);

function  CtlGetLabel(const controlP: ControlPtr):StringPtr; inline(SYSTRAP,$A113);
function  CtlGetValue(controlP:ControlPtr):UInt16;inline(SYSTRAP,$A111);
function  CtlNewControl(formP:FormPtr;objID:UInt16;style:Byte;const text:String;x,y,width,height:Coord;font:FontID;group:UInt8;leftAnchor:Boolean):ControlPtr; inline(SYSTRAP,$A32C);
function  CtlNewGraphicControl(formP:FormPtr;objID:UInt16;style:Byte;bitmapID,selectedBitmapID:UInt16;x,y,width,height:Coord;group:UInt8;leftAnchor:Boolean):ControlPtr; inline(SYSTRAP,$A3A9);
procedure CtlSetLabel(controlP:ControlPtr;const newLabel:StringPtr); inline(SYSTRAP,$A114);
procedure CtlSetValue(ControlP:ControlPtr;newValue:Int16); inline(SYSTRAP,$A112);

procedure DateToAscii(months,days:UInt8;years:UInt16;dateFormat:DateFormatType;var pString:String); inline(SYSTRAP,$A266);

function  DlkGetSyncInfo(var succSyncDateP,lastSyncDateP:UInt32;var syncStateP:DlkSyncStateType;var nameBufP,logBufP:string;var logLenP:Int32):UInt16; inline(SYSTRAP,$A2A9);

function  DmCloseDatabase(dbP:DmOpenRef):UInt16; inline(SYSTRAP,$A04A);
function  DmCreateDatabase(cardNo:UInt16;const name:String;c,t:UInt32;resDB:Boolean):UInt16; inline(SYSTRAP,$A041);
function  DmDatabaseInfo(cardNo:UInt16;dbID:LocalID;var name:String;var attributes,version:UInt16;var crDate,modDate,bkpUpDate,modNum:UInt32;var appInfoID,sortInfoID:LocalID;var t,c:UInt32):UInt16; inline(SYSTRAP,$A046);
function  DmDatabaseSize(cardNo:UInt16;dbID:LocalID;var numRecords,totalBytes,dataBytes:UInt32):Err; inline(SYSTRAP,$A048);
function  DmDeleteDatabase(cardNo:UInt16;dbID:LocalID):UInt16; inline(SYSTRAP,$A042);
function  DmFindDatabase(cardNo:UInt16;const name:String):LocalID; inline(SYSTRAP,$A045);
function  DmFindResource(dbP:DmOpenRef;ResType:UInt32;ResID:UInt16;resH:MemHandle):UInt16; inline(SYSTRAP,$A065);
function  DmGetDatabase(cardNo:UInt16;index:UInt16):LocalID; inline(SYSTRAP,$A044);
function  DmGetNextDatabaseByTypeCreator(newSearch:Boolean;var stateInfo:DmSearchStateType;t,c:UInt32;onlyLastVers:Boolean;var cardNo:UInt16;var dbIDP:LocalID):UInt16; inline(SYSTRAP,$A078);
function  DmGetRecord(dbP:DmOpenRef;index:UInt16):MemHandle; inline(SYSTRAP,$A05C);
function  DmGetResource(typ:UInt32;resID:UInt16):Memhandle; inline(SYSTRAP,$A05F);
function  DmGetResourceIndex(dbP:DmOpenRef;index:UInt16):MemHandle; inline(SYSTRAP,$A06E);
function  DmGet1Resource(resType: UInt32;resID: UInt16): MemHandle; inline(SYSTRAP,$A060);
function  DmNewRecord(dbP:DmOpenRef;var at:UInt16;size:UInt32):MemHandle; inline(SYSTRAP,$A055);
function  DmNewResource(dbP:DmOpenRef;ResType:UInt32;ResID:UInt16;size:UInt32):MemHandle; inline(SYSTRAP,$A06C);
function  DmNumDatabases(cardNo:UInt16):UInt16;inline(SYSTRAP,$A043);
function  DmNumRecords(dbP:DmOpenRef):UInt16; inline(SYSTRAP,$A04F);
function  DmNumRecordsInCategory(dbP:DmOpenRef;category:UInt16):UInt16; inline(SYSTRAP,$A071);
function  DmNumResources(dbP:DmOpenRef):UInt16; inline(SYSTRAP,$A067);
function  DmOpenDatabase(cardNo:UInt16;dbID:LocalID;mode:UInt16):DmOpenRef; inline(SYSTRAP,$A049);
function  DmOpenDatabaseByTypeCreator(typo,creator:UInt32;mode:UInt16):DmOpenRef; inline(SYSTRAP,$A075);
function  DmOpenDatabaseInfo(dbP:DmOpenRef;var dbIDP:LocalID;var openCountP,modeP,cardNoP:UInt16; var resDBP: Boolean):Err; inline(SYSTRAP,$A04C);
function  DmQueryRecord(dbP:DmOpenRef;index:UInt16):MemHandle; inline(SYSTRAP,$A05B);
function  DmRecordInfo(dbP:DmOpenRef;index:UInt16;var attrP:UInt16;var uniqueIDP:UInt32;var chunkIDP:LocalID):Err; inline(SYSTRAP,$A050);
function  DmReleaseRecord(dbP:DmOpenRef;index:UInt16;dirty:Boolean):UInt16; inline(SYSTRAP,$A05E);
function  DmReleaseResource(resourceH:MemHandle):Err; inline(SYSTRAP,$A061);
function  DmRemoveRecord(dbP:DmOpenRef;index:UInt16):Err; inline(SYSTRAP,$A056);
function  DmRemoveResource(dbP:DmOpenRef;index:UInt16):Err; inline(SYSTRAP,$A06D);
function  DmResourceInfo(dbP:DmOpenRef;index:UInt16;var ResTypeP:UInt32;var ResID:UInt16;var chunkLocalIDP:LocalID):Err; inline(SYSTRAP,$A068);
function  DmSet(rec:Pointer;offset:UInt32;bytes:UInt32;value:UInt8):UInt16; inline(SYSTRAP,$A07E);
function  DmSetDatabaseInfo(cardNo:UInt16;dbID:LocalID;const name:String;var attributes,version:UInt16;var crDate,modDate,bkpUpDate,modNum:UInt32;var appInfoID,sortInfoID:LocalID;var t,c:UInt32):UInt16; inline(SYSTRAP,$A047);
function  DmWrite(recordP:Pointer;offset:UInt32;srcP:Pointer;bytes:UInt32):UInt16; inline(SYSTRAP,$A076);

procedure EvtGetEvent(var event:EventType;timeout:UInt32); inline(SYSTRAP,$A11D);

procedure FldDrawField(fldP:FieldPtr); inline(SYSTRAP,$A135);
procedure FldGetAttributes(fldP:FieldPtr;var attrP:UInt16); inline(SYSTRAP,$A14F);
function  FldGetTextHandle(fldP:FieldPtr):MemHandle;inline(SYSTRAP,$A153);
function  FldGetTextLength(fldP:FieldPtr):UInt16;inline(SYSTRAP,$A14B);
function  FldGetTextPtr(fldP:FieldPtr):StringPtr; inline(SYSTRAP,$A139);
function  FldNewField(formP:FormPtr;ObjID:UInt16;x,y,width,height:Coord;font:FontID;maxChars:UInt32;editable:Boolean;underlined:UnderlineModeType;singleLine,dynamicSize:Boolean;justification:Byte;autoShift,hasScrollBar,numeric:Boolean):FieldPtr; inline(SYSTRAP,$A32D);
procedure FldSetAttributes(fldP:FieldPtr;var attrP:UInt16); inline(SYSTRAP,$A150);
procedure FldSetSelection(fldP:FieldPtr;startPosition,endPosition:UInt16); inline(SYSTRAP,$A142);
procedure FldSetTextHandle(fldP:FieldPtr;textHandle:MemHandle); inline(SYSTRAP,$A158);

procedure FntCharsInWidth(const Chars:String;var stringWidthP,stringLengthP:Int16;var fitWithinWidth:Boolean); inline(SYSTRAP,$A16D);
function  FntCharsWidth(const Chars:String;Len:Int16):Int16; inline(SYSTRAP,$A16B);
function  FntDefineFont(font:FontID;fontP:pointer):UInt16; inline(SYSTRAP,$A321);
function  FntGetFont:FontID; inline(SYSTRAP,$A163);
function  FntSetFont(font:FontID):FontID; inline(SYSTRAP,$A164);
function  FontSelect(font:FontID):FontID; inline(SYSTRAP,$A320);

function  FrmAlert(alertId:UInt16):UInt16; inline(SYSTRAP,$A192);
procedure FrmCloseAllForms;inline(SYSTRAP,$A1A1);
procedure FrmCopyLabel(FormP:FormPtr;labelID:UInt16;Const newLabel:String); inline(SYSTRAP,$A18C);
function  FrmCustomAlert(alertId:UInt16;const s1,s2,s3:String):UInt16; inline(SYSTRAP,$A194);
procedure FrmDeleteForm(FormP:FormPtr); inline(SYSTRAP,$A170);
function  FrmDispatchEvent(var event:EventType):Boolean; inline(SYSTRAP,$A1A0);
function  FrmDoDialog(formP:FormPtr):UInt16; inline(SYSTRAP,$A193);
procedure FrmDrawForm(FormP:FormPtr); inline(SYSTRAP,$A171);
procedure FrmEraseForm(FormP:FormPtr); inline(SYSTRAP,$A172);
function  FrmGetActiveForm:FormPtr; inline(SYSTRAP,$A173);
function  FrmGetFocus(formP:FormPtr):UInt16;inline(SYSTRAP,$A178);
function  FrmGetFormId(const formP:FormPtr):UInt16; inline(SYSTRAP,$A17D);
function  FrmGetFormPtr(formId:UInt16):FormPtr; inline(SYSTRAP,$A17E);
function  FrmGetLabel(formP:FormPtr;labelID:UInt16):StringPtr; inline(SYSTRAP,$A18E);
procedure FrmGetObjectBounds(formP:FormPtr;objIndex:UInt16;var r:RectangleType); inline(SYSTRAP,$A199);
function  FrmGetObjectId(formP:FormPtr;objIndex:UInt16):UInt16; inline(SYSTRAP,$A181);
function  FrmGetObjectIndex(formP:FormPtr;objID:UInt16):UInt16; inline(SYSTRAP,$A180);
function  FrmGetObjectPtr(formP:FormPtr;objIndex:UInt16):pointer; inline(SYSTRAP,$A183);
procedure FrmGotoForm(FormID:UInt16); inline(SYSTRAP,$A19B);
function  FrmHandleEvent(formP:FormPtr;var event:EventType):Boolean; inline(SYSTRAP,$A17A);
procedure FrmHelp(helpMsgId:UInt16); inline(SYSTRAP,$A195);
procedure FrmHideObject(formP:FormPtr;objIndex:UInt16); inline(SYSTRAP,$A184);
function  FrmInitForm(rscID:UInt16):FormPtr; inline(SYSTRAP,$A16F);
function  FrmNewLabel(formP:FormPtr;objID:UInt16;const textP:String;x,y:Coord;font:FontID):ControlPtr; inline(SYSTRAP,$A32F);
procedure FrmPopupForm(formId:UInt16); inline(SYSTRAP,$A19C);
function  FrmRemoveObject(formP:FormPtr;objIndex:UInt16):Err; inline(SYSTRAP,$A345);
procedure FrmReturnToForm(formId:UInt16); inline(SYSTRAP,$A19E);
procedure FrmSetActiveForm(FormP:FormPtr); inline(SYSTRAP,$A174);
procedure FrmSetControlGroupSelection(formP:FormPtr;groupNum:UInt8;controlID:UInt16); inline(SYSTRAP,$A18B);
procedure FrmSetControlValue(formP:FormPtr;objIndex:UInt16;newValue:UInt16); inline(SYSTRAP,$A189);
procedure FrmSetEventHandler(FormP:FormPtr;function handler(var event:Eventtype):Boolean); inline(SYSTRAP,$A19F);
procedure FrmSetFocus(formP:FormPtr;fieldIndex:UInt16);inline(SYSTRAP,$A179);
procedure FrmSetObjectBounds(formP:FormPtr;objIndex:UInt16;var r:RectangleType); inline(SYSTRAP,$A303);
procedure FrmSetObjectPosition(FormP:FormPtr;objIndex:UInt16;x,y:Coord); inline(SYSTRAP,$A187);
procedure FrmSetTitle(formP:FormPtr;const newTitle:string);inline(SYSTRAP,$A191);
procedure FrmShowObject(formP:FormPtr;objIndex:UInt16); inline(SYSTRAP,$A185);

function  FtrGet(creator:UInt32;featureNum:UInt16;var valueP:UInt32):Err; inline(SYSTRAP,$A27B);

function  GetCharCaselessValue:pointer; inline(SYSTRAP,$A296);

Procedure GsiInitialize; inline(SYSTRAP,$A29B);
Procedure GsiSetLocation(x,y:Int16); inline(SYSTRAP,$A29C);
Procedure GsiEnable(enableIt:Boolean); inline(SYSTRAP,$A29D);
Function  GsiEnabled:Boolean; inline(SYSTRAP,$A29E);
Procedure GsiSetShiftState(lockFlags,tempShift:UInt16); inline(SYSTRAP,$A29F);

procedure InsPtEnable(enableIt:Boolean); inline(SYSTRAP,$A1AB);
procedure InsPtSetHeight(Height:Int16); inline(SYSTRAP,$A1AD);
procedure InsPtSetLocation(x,y:Int16); inline(SYSTRAP,$A1A9);

function  KeyCurrentState:UInt32;inline(SYSTRAP,$A2A2);

procedure LstDrawList(ListP:ListPtr);inline(SYSTRAP,$A1B1);
procedure LstEraseList(ListP:ListPtr);inline(SYSTRAP,$A1B2);
function  LstGetNumberOfItems(ListP:ListPtr):Int16;inline(SYSTRAP,$A1BA);
function  LstGetSelection(ListP:ListPtr):Int16; inline(SYSTRAP,$A1B3);
function  LstGetSelectionText(ListP:ListPtr;intemNum:Int16):StringPtr; inline(SYSTRAP,$A1B4);
function  LstGetVisibleItems(ListP:ListPtr):Int16;inline(SYSTRAP,$A2FF);
procedure LstMakeItemVisible(ListP:ListPtr;itemNum:Int16); inline(SYSTRAP,$A0B9);
function  LstNewList(formP:FormPtr;id:UInt16;x,y,width,height:Coord;font:FontID;visibleItems,triggerId:Int16):Err; inline(SYSTRAP,$A32E);
function  LstPopupList(listP:ListPtr):Int16; inline(SYSTRAP,$A1BB);
function  LstScrollList(ListP:ListPtr;direction:WinDirectionType;itemCount:Int16):Boolean;inline(SYSTRAP,$A2FB);
procedure LstSetListChoices(listP:ListPtr;itemsText:Pointer;numItems:Int16); inline(SYSTRAP,$A1B8);
procedure LstSetSelection(ListP:ListPtr;itemNum:Int16); inline(SYSTRAP,$A1B7);
procedure LstSetTopItem(ListP:ListPtr;itemNum:Int16);inline(SYSTRAP,$A2B5);

function  MemCardInfo(cardNo:UInt16;var cardNameP,manufNameP:String;var versionP:UInt16;var crDateP,romSizeP,ramSizeP,freeBytesP:UInt32):Err; inline(SYSTRAP,$A004);
function  MemHandleFree(h: MemHandle):UInt16; inline(SYSTRAP,$A02B);
function  MemHandleLock(h:MemHandle):MemPtr; inline(SYSTRAP,$A021);
function  MemHandleNew(size:UInt32):MemHandle;inline(SYSTRAP,$A01E);
function  MemHandleSize(h:MemHandle):UInt32; inline(SYSTRAP,$A02D);
function  MemHandleUnlock(h:MemHandle):UInt16; inline(SYSTRAP,$A022);
function  MemHeapDynamic(heapID:UInt16):Boolean; inline(SYSTRAP,$A03E);
function  MemHeapFlags(heapID:UInt16):UInt16; inline(SYSTRAP,$A00D);
function  MemHeapFreeBytes(heapID:UInt16;var freeP,maxP:UInt32):Err; inline(SYSTRAP,$A00B);
function  MemHeapID(cardNo,heapIndex:UInt16):UInt16; inline(SYSTRAP,$A009);
function  MemHeapSize(heapID:UInt16):UInt32; inline(SYSTRAP,$A00C);
function  MemLocalIDKind(local:LocalID):LocalIDKind; inline(SYSTRAP,$A024);
function  MemLocalIDToPtr(local:LocalID;cardNo:UInt16):Pointer; inline(SYSTRAP,$A025);
procedure MemMove(var dst,s;numBytes:Int32); inline(SYSTRAP,$A026);
function  MemNumCards:UInt16; inline(SYSTRAP,$A03A);
function  MemNumHeaps(cardNo:UInt16):UInt16; inline(SYSTRAP,$A007);
function  MemPtrFree(p:MemPtr):UInt16; inline(SYSTRAP,$A012);
function  MemPtrHeapID(p:Pointer):UInt16; inline(SYSTRAP,$A018);
function  MemPtrNew(size:UInt32):MemPtr; inline(SYSTRAP,$A013);
function  MemPtrSetOwner(p:MemPtr;owner:UInt16):UInt16; inline(SYSTRAP,$A01B);
procedure MemSet(var dst;numBytes:integer;value:UInt8); inline(SYSTRAP,$A027);

procedure MenuEraseStatus(menuP:Pointer); inline(SYSTRAP,$A1C1);
function  MenuHandleEvent(menuP:Pointer;var event:EventType;var error:UInt16):Boolean; inline(SYSTRAP,$A1BF);

function  PrefGetAppPreferences(creator:UInt32;id:UInt16;var prefs;var prefsSize:UInt16;saved:Boolean):Int16; inline(SYSTRAP,$A2D3);
procedure PrefSetAppPreferences(creator:UInt32;id,version:UInt16;var prefs;prefsSize:UInt16;saved:Boolean); inline(SYSTRAP,$A2D4);

function  RctPtInRectangle(x,y:Coord;var r:RectangleType):Boolean; inline(SYSTRAP,$A1C8);
procedure RctSetRectangle(var r:RectangleType;left,top,width,height:Coord); inline(SYSTRAP,$A1C4);

procedure SclSetScrollBar(barP:ScrollBarPtr;value,min,max,pageSize:Int16); inline(SYSTRAP,$A2B6);

function  SelectDay(selectDayBy:SelectDayType;var month,day,year:Int16;Const title:String):Boolean; inline(SYSTRAP,$A2D0);
function  SelectOneTime(var hour,minute:Int16;Const title:String):Boolean; inline(SYSTRAP,$A34F);

procedure SndPlaySystemSound(beepID:Int8); inline(SYSTRAP,$A234);

function  StrAToI(const S:string):integer; inline(SYSTRAP,$a0ce);
function  StrCaselessCompare(const s1,s2:string):Int16; inline(SYSTRAP,$A0CA);
procedure StrCopy(dst:MemPtr;const src:String); inline(SYSTRAP,$A0C5);
procedure StrIToA(var S:string;N:integer); inline(SYSTRAP,$A0C9);
function  StrIToH(var s:String;i:UInt32):StringPtr; inline(SYSTRAP,$A0CB);
procedure StrNCopy(var dst:String;src:MemPtr;n:Int16); inline(SYSTRAP,$A2CE);
function  StrStr(const str,token:String):Pointer; inline(SYSTRAP,$A0CD);

function  SysBatteryInfo(doSet:Boolean;var warnThresholdP,criticalThresholdP:UInt16;var maxTicksP:Int16;var kindP:SysBatteryKind;var pluggedIn:Boolean;var percentP:UInt8):UInt16; inline(SYSTRAP,$A324);
function  SysCurAppDatabase(var cardNo:UInt16;var dbID:LocalID):UInt16; inline(SYSTRAP,$A0AC);
function  SysFormPointerArrayToStrings(c:Pointer;StringCount:Int16):MemHandle; inline(SYSTRAP,$A0C1);
function  SysHandleEvent(var event:EventType):Boolean; inline(SYSTRAP,$A0A9);
function  SysTaskDelay(delay:Int32):Err; inline(SYSTRAP,$A0A0);
function  SysTicksPerSecond:UInt16; inline(SYSTRAP,$A2E9);
function  SysUIAppSwitch(cardNo:UInt16;dbID:LocalID;cmd:UInt16;cmdPBP:Pointer):UInt16; inline(SYSTRAP,$A0A7);

Procedure TimeToAscii(hours,minutes:UInt8;timeFormat:TimeFormatType;var pString:String); inline(SYSTRAP,$A268);

function  TimGetSeconds:UInt32; inline(SYSTRAP,$A0F5);
function  TimGetTicks:UInt32; inline(SYSTRAP,$A0F7);
procedure TimSecondsToDateTime(seconds:UInt32;dateTimeP:DateTimePtr); inline(SYSTRAP,$A0FC);

function  UIPickColor(var indexP:IndexedColorType;var rgbP:RGBColorType;start:UInt16;const titleP,tipP:String):Boolean; inline(SYSTRAP,$A3AC);

function  WinCreateBitmapWindow(bitmapP:BitmapPtr;var error:UInt16):WinHandle; inline(SYSTRAP,$A3E4);
procedure WinDeleteWindow(win:WinHandle;eraseIt:boolean); inline(SYSTRAP,$A1F8);
procedure WinDrawBitmap(bitmapP:BitmapPtr;x,y:Coord); inline(SYSTRAP,$A226);
procedure WinDrawChars(const chars:string;len:Int16;x,y:Coord); inline(SYSTRAP,$A220);
procedure WinDrawChar(theChar:WChar;x,y:Coord); inline(SYSTRAP,$A350);
procedure WinDrawLine(x1,y1,x2,y2:Coord); inline(SYSTRAP,$A213);
procedure WinDrawRectangle(var r:RectangleType;cornerDiam:UInt16); inline(SYSTRAP,$A218);
procedure WinDrawRectangleFrame(frame:FrameType;var rP:RectangleType); inline(SYSTRAP,$A21B);
procedure WinDrawTruncChars(const chars:String;len:Int16;x,y,maxWidth:Coord); inline(SYSTRAP,$A351);
procedure WinEraseLine(x1,y1,x2,y2:Coord); inline(SYSTRAP,$A215);
procedure WinEraseRectangle(var r:RectangleType;cornerDiam:UInt16); inline(SYSTRAP,$A219);
procedure WinEraseRectangleFrame(frame:FrameType;var rP:RectangleType); inline(SYSTRAP,$A21D);
procedure WinIndexToRGB(i:IndexedColorType;var rgbP:RGBColorType); inline(SYSTRAP,$A39F);
procedure WinPopDrawState; inline(SYSTRAP,$A396);
procedure WinPushDrawState; inline(SYSTRAP,$A395);
function  WinRGBToIndex(var rgbP:RGBColorType):IndexedColorType; inline(SYSTRAP,$A39E);
function  WinScreenMode(operation:WinScreenModeOperation;var widthP,heightP,depthP:UInt32;var enableColorP:Boolean):Err; inline(SYSTRAP,$A33E);
function  WinSetDrawWindow(win:WinHandle):WinHandle; inline(SYSTRAP,$A1FD);
function  WinSetForeColor(foreColor:IndexedColorType):IndexedColorType; inline(SYSTRAP,$A398);
function  WinSetBackColor(foreColor:IndexedColorType):IndexedColorType; inline(SYSTRAP,$A399);
function  WinSetTextColor(foreColor:IndexedColorType):IndexedColorType; inline(SYSTRAP,$A39A);
function  WinSetDrawMode(newMode:WinDrawOperation):WinDrawOperation; inline(SYSTRAP,$A397);

// VFS functions
function  VFSDirEntryEnumerate(dirRef:UInt32;var dirEntryIteratorP:UInt32;var infoP:FileInfoType):Err; inline($7414,SYSTRAP,VFS_TRAP);
function  VFSFileClose(fileRefP:UInt32):Err; inline($7404,SYSTRAP,VFS_TRAP);
function  VFSFileOpen(volRefNum:UInt16;pathNameP:Pointer;openMode:UInt16;var fileRefP:UInt32):Err; inline($7403,SYSTRAP,VFS_TRAP);
function  VFSFileSize(fileRefP:UInt32;var fileSizeP:UInt32):Err; inline($7412,SYSTRAP,VFS_TRAP);
function  VFSVolumeEnumerate(var volRefNumP:UInt16;var volIteratorP:UInt32):Err; inline($741B,SYSTRAP,VFS_TRAP);
function  VFSVolumeGetLabel(volRefNum:UInt16;const labelP:String;bufLen:UInt16):Err; inline($741D,SYSTRAP,VFS_TRAP);
function  VFSVolumeSize(volRefNum:UInt16;var volumeUsedP:UInt32;var volumeTotalP:UInt32):Err; inline($741F,SYSTRAP,VFS_TRAP);

// HighRes functions
function  WinScreenGetAttribute(selector:WinScreenAttrType;var attrP:UInt32):Err; inline($740E,SYSTRAP,HIGH_DENSITY_TRAP);


// Special Functions

const
 V100 = $0100;
 V200 = $0200;
 V300 = $0300;
 V310 = $0310;
 V320 = $0320;
 V330 = $0330;
 V350 = $0350;
 V400 = $0400;
 V410 = $0410;
 V500 = $0500;

function  VersionSupported(MinVersion:UInt32):boolean;
var
 ErrNo:Err;
 ROMVersion:UInt32;
begin
 ErrNo:=FtrGet(sysFtrCreator,1,ROMVersion);
 VersionSupported:=ROMVersion>=MinVersion*$10000;
end;

function  HandlerNONE(var e:EventType):boolean;
// Needed for Palm OS < v3
begin
  HandlerNONE:=false;
end;
